• The MGLAnnotation protocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate objects to handle the display.

    An object that adopts this protocol must implement the coordinate property. The other methods of this protocol are optional.

    See more

    Declaration

    Objective-C

    @protocol MGLAnnotation <NSObject>

    Swift

    protocol MGLAnnotation : NSObjectProtocol
  • The MGLOverlay protocol defines a specific type of annotation that represents both a point and an area on a map. Overlay objects are essentially data objects that contain the geographic data needed to represent the map area. Overlays can take the form of a polyline or polygon.

    You use overlays to layer more sophisticated content on top of a map view. For example, you could use an overlay to show the boundaries of a national park or trace a bus route along city streets. This SDK defines several concrete classes that conform to this protocol and define standard shapes.

    See more

    Declaration

    Objective-C

    @protocol MGLOverlay <MGLAnnotation>

    Swift

    protocol MGLOverlay : MGLAnnotation
  • The MGLMultiPoint class is an abstract superclass used to define shapes composed of multiple vertices.

    You do not create instances of this class directly. Instead, you create instances of the MGLPolyline or MGLPolygon classes. However, you can use the method and properties of this class to access information about the vertices of the line or polygon.

    Do not confuse MGLMultiPoint with MGLPointCollection, which represents a collection of related but disconnected points.

    See more

    Declaration

    Objective-C

    @interface MGLMultiPoint : MGLShape

    Swift

    class MGLMultiPoint : MGLShape
  • An MGLPolygon object represents a closed shape consisting of four or more vertices, specified as CLLocationCoordinate2D instances, and the edges that connect them. For example, you could use a polygon shape to represent a building, a lake, or an area you want to highlight.

    You can add polygon shapes to the map by adding them to an MGLShapeSource object. Configure the appearance of an MGLShapeSource’s or MGLVectorSource’s polygons collectively using an MGLFillStyleLayer or MGLSymbolStyleLayer object.

    Alternatively, you can add a polygon overlay directly to a map view using the -[MGLMapView addAnnotation:] or -[MGLMapView addOverlay:] method. Configure a polygon overlay’s appearance using -[MGLMapViewDelegate mapView:strokeColorForShapeAnnotation:] and -[MGLMapViewDelegate mapView:fillColorForPolygonAnnotation:].

    The vertices are automatically connected in the order in which you provide them. You should close the polygon by specifying the same CLLocationCoordinate2D as the first and last vertices; otherwise, the polygon’s fill may not cover the area you expect it to. To avoid filling the space within the shape, give the polygon a transparent fill or use an MGLPolyline object.

    A polygon may have one or more interior polygons, or holes, that you specify as MGLPolygon objects with the +polygonWithCoordinates:count:interiorPolygons: method. For example, if a polygon represents a lake, it could exclude an island within the lake using an interior polygon. Interior polygons may not themselves have interior polygons. To represent a shape that includes a polygon within a hole or, more generally, to group multiple polygons together in one shape, use an MGLMultiPolygon or MGLShapeCollection object.

    To make the polygon straddle the antimeridian, specify some longitudes less than −180 degrees or greater than 180 degrees.

    See more

    Declaration

    Objective-C

    @interface MGLPolygon : MGLMultiPoint <MGLOverlay>

    Swift

    class MGLPolygon : MGLMultiPoint, MGLOverlay
  • An MGLMultiPolygon object represents a shape consisting of one or more polygons that do not overlap. For example, you could use a multipolygon shape to represent the body of land that consists of an island surrounded by an atoll: the inner island would be one MGLPolygon object, while the surrounding atoll would be another. You could also use a multipolygon shape to represent a group of disconnected but related buildings.

    You can add multipolygon shapes to the map by adding them to an MGLShapeSource object. Configure the appearance of an MGLShapeSource’s or MGLVectorSource’s multipolygons collectively using an MGLFillStyleLayer or MGLSymbolStyleLayer object.

    You cannot add an MGLMultiPolygon object directly to a map view using -[MGLMapView addAnnotation:] or -[MGLMapView addOverlay:]. However, you can add the polygons array’s items as overlays individually.

    See more

    Declaration

    Objective-C

    @interface MGLMultiPolygon : MGLShape <MGLOverlay>

    Swift

    class MGLMultiPolygon : MGLShape, MGLOverlay